package com.wzy.business.store.me

import com.wangzhenyu.common.loadmore.BaseLoadActivity
import com.wangzhenyu.common.loadmore.LoadMoreAdapter
import com.wangzhenyu.common.util.log.LogUtil
import com.wzy.business.R
import com.wzy.business.databinding.ActivityHelpDocBinding
import com.wzy.business.store.me.adapter.HelpDocAdapter
import com.wzy.business.store.me.bean.Article
import com.wzy.business.store.me.presenter.HelpDocPresenter
import com.wzy.business.store.me.presenter.impl.HelpDocPresenterImpl


//在这里测试Android的自动加载
class HelpDocActivity : BaseLoadActivity<Article.DataX, ActivityHelpDocBinding, HelpDocPresenter>(),
    HelpDocPresenter.View {

    override fun getViewBinding() = ActivityHelpDocBinding.inflate(layoutInflater)

    override fun createPresenter() = HelpDocPresenterImpl(this)

    override fun useBaseLayout() = true

    override fun useLightMode() = false

    override fun createAdapter(): LoadMoreAdapter<Article.DataX> =
        HelpDocAdapter(R.layout.item_base_type_one)

    override fun loadMore() {
        mPresenter?.queryContentList(pageInfo.page, getPageSize())
    }

    override fun initAdapter() {
        super.initAdapter()
        //设置Item的点击事件
        adapter.setOnItemClickListener { _, _, _ ->
            LogUtil.d("WZYTest", "Item被点击了")
        }
        //设置Item内子控件的点击
        // 先注册需要点击的子控件id（注意，请不要写在convert方法里）
        adapter.addChildClickViewIds(R.id.item_bto_button)
        adapter.setOnItemChildClickListener { _, view, _ ->
            if (view.id == R.id.item_bto_button) {
                LogUtil.d("WZYTest", "Item内的子Item被点击了")
            }
        }

    }

    override fun initView() {
        super.initView()
        mToolBarDelegate?.setMidTitle("帮助中心")
    }


    override fun loadDataSuccess(data: List<Article.DataX>) {
        loadMoreSuccess(data)
    }

    override fun loadDataFail() {
        loadDataFail()
    }

}